package com.maple.soa.base;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;

/**
 * Servlet初识，获取常见参数、配置信息等
 * @author lijian
 * @date 2020/6/26
 */
@WebServlet(urlPatterns = "/request")
public class RequestServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        System.out.println(req.getServletPath());
        System.out.println(req.getContextPath());

        ServletContext application = req.getServletContext();
        System.out.println(application.getRealPath("WEB-INF/upload"));

        System.out.println(req.getRemoteUser());

    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
